package jdbctest;

import java.sql.*;

/**
 * Created by Administrator on 2017/9/11.
 */
public class InsertTest {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //加载驱动
        Class.forName("com.mysql.jdbc.Driver");

        //连接数据库
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3307/user","root","123456");

        //操作数据(插入数据)
        Statement statement = conn.createStatement();
        String sql = "insert into usertable(id,password,room) values (4,'dfsdff','ghjgj')";
        statement.executeUpdate(sql);

        //关闭资源
        statement.close();
        conn.close();
    }
}
